package cn.jc.springframework.beans.factory.support;

import cn.jc.springframework.beans.BeansException;
import cn.jc.springframework.beans.factory.config.BeanDefinition;

/**
 * @Description:
 * @author: JC
 * @date: 2022/5/30 18:14
 */
public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFactory{


    @Override
    protected Object createBean(String name, BeanDefinition beanDefinition) throws BeansException {
        Object bean = null;
        try {
            bean = beanDefinition.getBeanClass().newInstance();
        } catch (Exception e) {
            throw new BeansException("Instantiation of bean failed");
        }
        addSingleton(name, bean);
        return bean;
    }

}
